<template>
	<view class="">
		<u-navbar :background="background" :border-bottom="false"></u-navbar>
		<view class="h80"></view>
		<view class=" radius20 bg-fff px30 py44 m20 loginBoxShadow">
			<view class="flex mb30">
				<image :src="$config.shop_logo" class="h92 w92 radius20" mode=""></image>
				<view class="fs36 fw-600 ml24">
					账号密码注册
				</view>
			</view>
			<u-form :borderBottom="false">
				<u-form-item>
					<view class="p10 pl30 pr30 w-max bg-f8f radius20">
						<u-input v-model="form.mobile" maxlength="11" placeholder="请输入手机号码"></u-input>
					</view>
				</u-form-item>
				<u-form-item>
					<view class="p10 pl30 pr30 w-max bg-f8f radius20 flex row-between">
						<u-input v-model="form.code" class="flex1" placeholder="请输入短信验证码"></u-input>
						<tips :mobile="form.mobile" type="accountRegister" />
					</view>
				</u-form-item>
				<u-form-item>
					<view class="p10 pl30 pr30 w-max bg-f8f radius20">
						<u-input v-model="form.password" type="password" placeholder="请输入登录密码"></u-input>
					</view>
				</u-form-item>
				<u-form-item>
					<view class="p10 pl30 pr30 w-max bg-f8f radius20">
						<u-input v-model="form.password2" type="password" placeholder="请确认登录密码"></u-input>
					</view>
				</u-form-item>
				<u-form-item>
					<view class="p10 pl30 pr30 w-max bg-f8f radius20">
						<u-input v-model="form.invite_code" placeholder="如有邀请码请填入 没有不填"></u-input>
					</view>
				</u-form-item>
			</u-form>
			<view class="flex row-between mt30 mb40 color-666">
				<view class="" @click="$tool.reUrl('/pages/public/login')">去登录</view>
			</view>
			<u-button type="warning" class="mt50 radius20" ripple @click="submit">确定</u-button>

			<view class="flex fs24 mt20" @click="isLook=!isLook">
				<radio :checked="isLook" class="scale7 pe-none" :color="$zs" />
				<view class="color-999">已阅读并同意</view>
				<view class="color-zs"
					@click.stop="$u.route('/pages/public/text',{text:'service_agreement',tit:'用户协议'})">《用户协议》</view>
				<view class="color-999">与</view>
				<view class="color-zs" @click.stop="$u.route('/pages/public/text',{text:'privacy_policy',tit:'隐私政策'})">
					《隐私政策》</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isLook: false,
				form: {
					mobile: '',
					code: '',
					password: '',
					password2: '',
					invite_code: ''
				},
				captcha: '',
				uuid: {
					img_src: "",
					uuid: ""
				},
				background: {
					backgroundColor: 'transparent',
				}
			};
		},
		onLoad(e) {
			this.form.invite_code = e.regcode || uni.getStorageSync('regcode') || ""
		},
		methods: {
			submit() {
				if (!this.isLook) return this.$msg('请同意协议')
				if (!this.form.mobile) return this.$msg('手机号不能为空')
				if (!this.form.code) return this.$msg('验证码不能为空')
				if (!this.form.password) return this.$msg('密码不能为空')
				if (this.form.password != this.form.password2) return this.$msg('密码不一致')
				this.$request('/master/auth/register', this.form).then(res => {
					this.$msg(res.msg)
					setTimeout(() => {
						this.$tool.rjump('/pages/public/login')
					}, 1000)
				})
			},
			// getUuid() {
			// 	this.$request('/system/sms/get_img_code').then(res => {
			// 		this.uuid=res.data
			// 	})
			// }
		}
	}
</script>

<style lang="scss">
	page {
		min-height: 100%;
		background: $page_bg;
	}
</style>